// 定义默认数据
// 定義數據字段類型
interface IdefaultState {
    num: number
}
const defaultState: IdefaultState = {
    num: 0
}

// 导出函数
interface Iaction {
    type: string,
    value?: any
}


const fn = (state = defaultState, action: Iaction) => {
    let newState = JSON.parse(JSON.stringify(state))
    switch (action.type) {
        case 'increase':
            newState.num = newState.num + action.value
            break
        default:
            break
    }

    return newState
}
export default fn